import 'package:inmotion_pro/service/realtime_data_server/vehicle_realtime_data/vehicle_data_base.dart';
import 'package:safemap/safemap.dart';

class VehicleSettings extends VehicleDataBase {
  int voicePacketIndex = 0; // 当前语音包号 范围 0~(0xFFFFFFFF-1)，0xFFFFFFFF表示当前没有语音包
  int rgbPacketIndex = 0; // 当前RGB灯包号 范围 0~(0xFFFFFFFF-1)，0xFFFFFFFF表示当前没有语音包
  int limitSpeed = 0; // 限速 单位0.01km/h 范围 0~8000
  int limitSpeedWarningLevel1 = 0; // 限速警告1 单位0.01km/h 范围 0~8000
  int limitSpeedWarningLevel2 = 0; // 限速警告2 单位0.01km/h 范围 0~8000
  int pitchZero = 0; // 平衡角度零点 单位0.01° 范围 -1000~1000
  int standByTime = 0; // 待机时间 单位S 范围 0~64800(18h) 0代表永不自动关机
  int driverMode = 0; // 驱动模式 0舒适模式 1经典模式
  int rideMode = 0; // 骑行模式 0普通模式 1发烧者模式
  int sensation1 = 0; // 舒适模式软硬度 单位1% 范围 0~100
  int sensation2 = 0; // 经典模式软硬度 单位1% 范围 0~100
  int voiceVolume = 0; // 音量 单位1% 范围 0~100
  int rgbLightMode = 0; // RGB灯模式 0关闭 1使用音效文件 2跟随音乐波动
  int lowThreshold = 0; // 照明灯开启的光照强度阈值 单位1% 范围 0~100
  int highThreshold = 0; // 照明灯关闭的光照强度阈值 单位1% 范围 0~100
  int lowLampBrightness = 0; // 手动设置近光灯照明灯亮度 单位1% 范围 0~100
  int highLampBrightness = 0; // 手动设置远光灯照明亮度 单位1% 范围 0~100
  int activeSoundSensitivity = 0; // 主动声浪灵敏度 单位1% 范围 0~100
  int highLampAutoSwitchSpeed = 0; // 自动切换远近光速度阈值 单位0.01km/h 范围 0~8000
  int speedingFeedback = 0; // 加速反馈 单位1% 范围 -100~100
  int brakingFeedback = 0; // 刹车反馈 单位1% 范围 -100~100

  bool audioSwitch = false; // 语音功能 0关闭 1开启
  bool turnSignalLight = false; // 转向灯功能 0关闭 1开启
  bool liftUpDetection = false; // 防飞转开关 0关闭 1开启
  bool lampAutoSwitch = false; // 照明灯自动开关 0关闭 1开启
  bool autoBrightness = false; // 照明灯自动亮度调节 0关闭 1开启
  bool lockMode = false; // 锁车 0关闭 1开启
  bool transportMode = false; // 运输模式 0关闭 1开启
  bool loadDetect = false; // 负载检测 0关闭 1开启
  bool noLoadDetect = false; // 空载检测 0关闭 1开启
  bool lowBatteryRide = false; // 是否允许低电骑行 0不允许 1允许
  bool activeSound = false; // 主动声浪 0关闭 1开启
  bool touchKey = false; // 触摸快捷键 0关闭 1开启
  bool usbPowerSwitch = false; // USB电源开关 0关闭 1开启
  bool autoCloseScreen = false; // 自动息屏开关 0关闭 1开启
  bool rangeEstimate = false; // 剩余里程估算 0关闭 1开启
  bool assistBalance = false; // 辅助平衡开关 0关闭 1开启
  bool acceFeedback = false; // 加减速反馈开关 0关闭 1开启
  bool bermAngleMode = false; // 赛道倾角开关 0关闭 1开启
  bool logoLightStatus = false; // logo灯开关 0关闭 1开启
  bool tboxLowBatWakeUp = false; // 云盒低电唤醒功能  0 关闭  1 开启
  bool showTboxInfo = false; // 云盒信息显示开关  0 关闭  1 开启

  VehicleSettings.fromMap(Map<String, dynamic>? data) : super.fromMap(data) {
    SafeMap safeMap = SafeMap(data);
    rideMode = safeMap['rideMode'].toInt ?? 0;
    voicePacketIndex = safeMap['voicePacketIndex'].toInt ?? 0;
    rgbPacketIndex = safeMap['rgbPacketIndex'].toInt ?? 0;
    limitSpeed = safeMap['limitSpeed'].toInt ?? 0;
    limitSpeedWarningLevel1 = safeMap['limitSpeedWarningLevel1'].toInt ?? 0;
    limitSpeedWarningLevel2 = safeMap['limitSpeedWarningLevel2'].toInt ?? 0;
    pitchZero = safeMap['pitchZero'].toInt ?? 0;
    standByTime = safeMap['standByTime'].toInt ?? 0;
    driverMode = safeMap['driverMode'].toInt ?? 0;
    sensation1 = safeMap['sensation1'].toInt ?? 0;
    sensation2 = safeMap['sensation2'].toInt ?? 0;
    voiceVolume = safeMap['voiceVolume'].toInt ?? 0;
    rgbLightMode = safeMap['rgbLightMode'].toInt ?? 0;
    lowThreshold = safeMap['lowThreshold'].toInt ?? 0;
    highThreshold = safeMap['highThreshold'].toInt ?? 0;
    lowLampBrightness = safeMap['lowLampBrightness'].toInt ?? 0;
    highLampBrightness = safeMap['highLampBrightness'].toInt ?? 0;
    activeSoundSensitivity = safeMap['activeSoundSensitivity'].toInt ?? 0;
    highLampAutoSwitchSpeed = safeMap['highLampAutoSwitchSpeed'].toInt ?? 0;
    speedingFeedback = safeMap['speedingFeedback'].toInt ?? 0;
    brakingFeedback = safeMap['brakingFeedback'].toInt ?? 0;
    audioSwitch = safeMap['audioSwitch'].boolean;
    turnSignalLight = safeMap['turnSignalLight'].boolean;
    liftUpDetection = safeMap['liftUpDetection'].boolean;
    lampAutoSwitch = safeMap['lampAutoSwitch'].boolean;
    autoBrightness = safeMap['autoBrightness'].boolean;
    lockMode = safeMap['lockMode'].boolean;
    transportMode = safeMap['transportMode'].boolean;
    loadDetect = safeMap['loadDetect'].boolean;
    noLoadDetect = safeMap['noLoadDetect'].boolean;
    lowBatteryRide = safeMap['lowBatteryRide'].boolean;
    activeSound = safeMap['activeSound'].boolean;
    touchKey = safeMap['touchKey'].boolean;
    usbPowerSwitch = safeMap['usbPowerSwitch'].boolean;
    autoCloseScreen = safeMap['autoCloseScreen'].boolean;
    rangeEstimate = safeMap['rangeEstimate'].boolean;
    assistBalance = safeMap['assistBalance'].boolean;
    acceFeedback = safeMap['acceFeedback'].boolean;
    bermAngleMode = safeMap['bermAngleMode'].boolean;
    logoLightStatus = safeMap['logoLightStatus'].boolean;
    tboxLowBatWakeUp = safeMap['tboxLowBatWakeUp'].boolean;
    showTboxInfo = safeMap['showTboxInfo'].boolean;
  }

  // 复制
  VehicleSettings copy() {
    VehicleSettings copy = VehicleSettings.fromMap(toMap());
    return copy;
  }

  Map<String, dynamic> toMap() {
    return {
      'rideMode': rideMode,
      'voicePacketIndex': voicePacketIndex,
      'rgbPacketIndex': rgbPacketIndex,
      'limitSpeed': limitSpeed,
      'limitSpeedWarningLevel1': limitSpeedWarningLevel1,
      'limitSpeedWarningLevel2': limitSpeedWarningLevel2,
      'pitchZero': pitchZero,
      'standByTime': standByTime,
      'driverMode': driverMode,
      'sensation1': sensation1,
      'sensation2': sensation2,
      'voiceVolume': voiceVolume,
      'rgbLightMode': rgbLightMode,
      'lowThreshold': lowThreshold,
      'highThreshold': highThreshold,
      'lowLampBrightness': lowLampBrightness,
      'highLampBrightness': highLampBrightness,
      'activeSoundSensitivity': activeSoundSensitivity,
      'highLampAutoSwitchSpeed': highLampAutoSwitchSpeed,
      'speedingFeedback': speedingFeedback,
      'brakingFeedback': brakingFeedback,
      'audioSwitch': audioSwitch ? 1 : 0,
      'turnSignalLight': turnSignalLight ? 1 : 0,
      'liftUpDetection': liftUpDetection ? 1 : 0,
      'lampAutoSwitch': lampAutoSwitch ? 1 : 0,
      'autoBrightness': autoBrightness ? 1 : 0,
      'lockMode': lockMode ? 1 : 0,
      'transportMode': transportMode ? 1 : 0,
      'loadDetect': loadDetect ? 1 : 0,
      'noLoadDetect': noLoadDetect ? 1 : 0,
      'lowBatteryRide': lowBatteryRide ? 1 : 0,
      'activeSound': activeSound ? 1 : 0,
      'touchKey': touchKey ? 1 : 0,
      'usbPowerSwitch': usbPowerSwitch ? 1 : 0,
      'autoCloseScreen': autoCloseScreen ? 1 : 0,
      'rangeEstimate': rangeEstimate ? 1 : 0,
      'assistBalance': assistBalance ? 1 : 0,
      'acceFeedback': acceFeedback ? 1 : 0,
      'bermAngleMode': bermAngleMode ? 1 : 0,
      'logoLightStatus': logoLightStatus ? 1 : 0,
      'tboxLowBatWakeUp': tboxLowBatWakeUp ? 1 : 0,
      'showTboxInfo': showTboxInfo ? 1 : 0,
    };
  }
}
